package com.vilen.L_1;

import java.io.UnsupportedEncodingException;

/**
 * Created by vilen on 2015/3/30.
 */
public class EncodingDemo {
    public static void main(String[] args) throws Exception {
        String s = "慕课ABC";
        byte[] bytes =s.getBytes();//默认编码
        for(byte b: bytes){
            //把字节转换成16进制的形式
            //System.out.print(Integer.toHexString(b));
            System.out.print(Integer.toHexString(b & 0xff)+" ");
        }
        System.out.println();
        byte[] bytes2 = s.getBytes("UTF-8");
        for(byte b:bytes2) {
            System.out.print(Integer.toHexString(b & 0xff) + " ");
        }
        System.out.println();
//        byte[] bytes3 = s.getBytes("gbk");
//        for (byte b: bytes3) {
//            System.out.print(Integer.toHexString(b & 0xff) + " ");
//        }
        /*
         * 文本文件 ansi 编码
         */
    }
}
